<template>
  <el-dialog
    :visible.sync="rechargeShow"
    :before-close="handleClose"
    width="30%"
    title="充值易货积分"
  >
    <el-form class="form">
      <el-form-item label="用户ID">
        <el-input
          readonly
          v-model="form.uid"
          placeholder="请输入用户ID"
        ></el-input>
      </el-form-item>
      <el-form-item label="数量">
        <el-input
          v-model.number="form.number"
          placeholder="请输入易货积分数量"
        ></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submit">提交</el-button>
      </el-form-item>
    </el-form>
  </el-dialog>
</template>
<script>
import { userRecharge } from "@/api/ds/user";
export default {
  components: {},
  props: {
    rechargeShow: {
      type: Boolean,
      default: false,
    },
    uid: {
      type: [Number, String],
      default: "",
    },
  },
  data() {
    return {
      form: { uid: "", number: 0 },
    };
  },
  computed: {},
  watch: {
    uid(newValue) {
      this.form.uid = newValue;
    },
  },
  created() {},
  methods: {
    async submit() {
      let res = await userRecharge(this.form);
      if (res.code === 200) {
        this.$notify({
          type: "success",
          message: res.msg,
        });

        this.form = { uid: "", number: 0 };
        this.$emit("refresh");
        this.$emit("close");
      }
    },

    handleClose(done) {
      this.$emit("close");
      done();
    },
  },
  mounted() {},
  beforeCreate() {},
  beforeMount() {},
  beforeUpdate() {},
  updated() {},
  beforeDestroy() {},
  destroyed() {},
  activated() {},
  deactivated() {},
};
</script>
<style lang="scss" scoped>
.page {
  padding: 20px;

  .form {
    width: 800px;
  }
}
</style>
